Page({
  data:{
    catelist:["男装","女装","零食","家电","床上用品","家具"],
    banners:[
      {url:"/images/4.jpg"},
      {url:"/images/2.jpg"},
      {url:"/images/5.jpg"}
  ],
  danmulist:[{
    text:"湖南网络工程学院",
    color:"#ff0000",
    time:2
  },
{
  text:"信息学院",
  color:"#ff0000",
  time:3
}],
markers:[{
latitude:28.135653,
longitude:112.988432,
name:"网院"
}],
longitude:"",
latitude:""
  },

  onLoad(){
     this.addStorage();
     this.getLocal();
     this.share();
  },
  addStorage:function(){
       wx.setStorage({
         data: {"name":"陈子杨","studentid":"201965110545"},
         key: 'userinfo',
       })
       wx.setStorageSync('user', {"age":"21","sex":"男"})
  },
//获取当前经纬度
getLocal:function(){
  var then=this;
     wx.getLocation({
       
       type:'gcj02',//设置当前返回GPS位置
       isHighAccuracy:true,
       success(res){
         console.log(res)
        //  this.openLocal(res);
        then.setData({
          latitude:res.latitude,
          longitude:res.longitude
        });
       }
     })
},
openLocal:function(res){
  var then=this;
  wx.openLocation({
    latitude:then.data.latitude,
    longitude: then.data.longitude,
    name:"湖南开放大学",
    address:"湖南省长沙市天心区青园路168号实训楼113"

    
  })
},
chooseLocal:function(){
  var then=this;
  wx.chooseLocation({
    latitude: then.data.latitude,
    longitude:then.data.longitude,
    success(res){
      console.log(res);
    }
    
  })
},
selectImg:function(){
     wx.chooseImage({
       count: 1,
       sourceType:['camera'],
       success(res){
                console.log(res)
                wx.previewImage({
                  urls: [res.tempFilePaths[0]],
                  showmenu:true
                })
                wx.getImageInfo({
                  src: 'res.tempFilePaths[0]',
                  success(res){
                    console.log(res)
                  }
                  
                })
       }
     })
},
saveImag:function(){
  wx.getImageInfo({
    src: '../../images/banner1.jpg',
    success(res){
      wx.saveImageToPhotosAlbum({
        filePath:res.path,
      })
    }
  })
  
},
call:function(){
wx.makePhoneCall({
  phoneNumber: '16673192565',
})
},
scanCode:function(){
        wx.scanCode({
          onlyFromCamera: true,
          success(res){
            console.log(res)
          }
        })
},
share:function(){
  wx.showShareMenu({
    withShareTicket: true,
    menus:['shareAppMessage','shareTimeline']
  })
},
onShareAppMessage:function(){
  return{
    title:"湖南开放大学",
    path:"/pages/car/car",
    imageUrl:"../../images/5.jpg"
  }
},
onShareTimeline(){
  return{
  title:"今日抢购送10000元大礼包",
  query:"car?id=4",
  imageUrl:"../../images/5.jpg"
  }
},
   getShareinfo:function(){
     wx.getShareInfo({
       shareTicket: 'shareTicket',
       success(res){
         console.log(res)
       }
     })
   }
})
